package service

import (
	"fmt"
	"strings"
)

func BuildVersionInt(version string) int {
	versionInt := 0
	mainVer := 0
	midVer := 0
	minVer := 0
	detailVer := 0
	list := strings.Split(version, ".")

	versionCount := len(list)
	if versionCount < 3 || versionCount > 4 {
		return versionInt
	}

	if len(list) == 3 {
		version = fmt.Sprintf("%s.0", version)
	}

	fmt.Sscanf(version, "%d.%d.%d.%d", &mainVer, &midVer, &minVer, &detailVer)
	versionInt = mainVer*1000*1000*100 + midVer*1000*100 + minVer*100 + detailVer
	return versionInt
}
